<?php
namespace app\admin\model\develop;
use think\Model;

class CrontabLog extends Model
{
    protected $name='crontab_log';
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';
    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    // 定义字段类型
    protected $type = [
    ];
    // 追加属性
    protected $append = [
    ];

    public function getStatusList()
    {
        return ['normal' =>'正常', 'hidden' =>'隐藏'];
    }

    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getList($cid){
        if($cid!==0){
            return  $this->where('crontab_id',$cid)->order( 'id desc')
            ->paginate(15, false, [
                'query' => request()->request()
            ]);
        }else{
            return $this->order( 'id desc')
                ->paginate(15, false, [
                    'query' => request()->request()
                ]);
        }


    }

    public function detail($id){
      return  $this->where('id',$id)->find();

    }

    public function del($id)
    {
        return  $this->where('id',$id)->delete();
    }

}